using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ACME.Northwind.DataTransfer;
using System.Linq.Expressions;
using ACME.Northwind.Service.Interfaces;

namespace ACME.Northwind.WCFProxy
{
	/// <summary>
	/// The service implementation for EmployeeTerritory object
	/// </summary>
	public partial class EmployeeTerritoryService : IEmployeeTerritoryService
	{
		#region IEmployeeTerritoryService Members

		/// <summary>
		/// Run a selection by the primary key
		/// </summary>
		public EmployeeTerritoryDTO SelectByPrimaryKey(int employeeid, string territoryid)
		{
			return DataService.Instance.GetEmployeeTerritory(employeeid, territoryid);
		}

		/// <summary>
		/// Run the persist for a list
		/// </summary>
		public bool Persist(List<EmployeeTerritoryDTO> list)
		{
			bool retval = true;
			foreach (EmployeeTerritoryDTO employeeterritory in list)
			{
				retval &= this.Persist(employeeterritory);
			}
			return retval;
		}

		/// <summary>
		/// Run the persist for an object
		/// </summary>
		public bool Persist(EmployeeTerritoryDTO dto)
		{
			return (DataService.Instance.PersistEmployeeTerritory(dto) != null);
		}

		/// <summary>
		/// Run a selection using LINQ
		/// </summary>
		public List<EmployeeTerritoryDTO> RunSelect(string linq)
		{
			List<EmployeeTerritoryDTO> retVal = new List<EmployeeTerritoryDTO>();
			retVal.AddRange(DataService.Instance.GetEmployeeTerritoryListByLINQ(linq));
			return retVal;
		}

		/// <summary>
		/// Run a paginated selection using LINQ
		/// </summary>
		public PagedQueryResults<EmployeeTerritoryDTO> RunSelect(int pageIndex, int pageSize, bool ascending, string sortColumn, string linq)
		{
			return DataService.Instance.GetEmployeeTerritoryListPaged(pageIndex, pageSize, ascending, sortColumn, linq);
		}

		/// <summary>
		/// Run a selection for all objects
		/// </summary>
		public List<EmployeeTerritoryDTO> RunSelect()
		{
			List<EmployeeTerritoryDTO> retVal = new List<EmployeeTerritoryDTO>();
			DataServiceClient ds = DataService.Instance;
			retVal.AddRange(ds.GetEmployeeTerritoryList());
			return retVal;
		}

		/// <summary>
		/// Return the related Employee item
		/// </summary>
		public EmployeeDTO GetEmployeeItem(EmployeeTerritoryDTO item)
		{
			EmployeeDTO retval = new EmployeeDTO();
			DataServiceClient ds = DataService.Instance;
			retval = ds.GetEmployee(item.EmployeeId);
			return retval;
		}

		/// <summary>
		/// Return the related Territory item
		/// </summary>
		public TerritoryDTO GetTerritoryItem(EmployeeTerritoryDTO item)
		{
			TerritoryDTO retval = new TerritoryDTO();
			DataServiceClient ds = DataService.Instance;
			retval = ds.GetTerritory(item.TerritoryId);
			return retval;
		}

		/// <summary>
		/// Delete the specified item
		/// </summary>
		public bool Delete(EmployeeTerritoryDTO item)
		{
			DataServiceClient ds = DataService.Instance;
			return ds.DeleteEmployeeTerritory(item);
		}

		#endregion
	}
}
